home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17496 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  47 lines

  1. Path: lf.hp.com!gajdos
  2. From: gajdos@lf.hp.com (Larry Gajdos)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: HELP ! => Problem compiling STL classes in Visual C++ 4.1.
  5. Date: 15 Apr 1996 15:05:50 GMT
  6. Organization: Hewlett-Packard Little Falls Site
  7. Message-ID: <4ktoke$o99@hpavua.lf.hp.com>
  8. References: <4kh12t$rs0@newsbf02.news.aol.com>
  9. NNTP-Posting-Host: gajdos@eden.lf.hp.com
  10. X-Newsreader: TIN [version 1.2 PL2.2]
  11.  
  12. Pete Becker's comments on namespace seem to be ringing true since I am
  13. continually running into problems incorporating namespaces, as suggested
  14. by Microsoft in their readme files accompanying the STL.
  15.  
  16. However, the compiler error problem you mentioned can be solved by
  17. problem by including new.h (a C library header file) _before_ including
  18. any STL files. (I'm assuming you've made the 10 or so changes
  19. recommended by Microsoft--sprinkling "std::"'s in place of "::"'s.)
  20. By the way, I have found it useful to recognize that the line ,
  21. "#define std", undoes all of those edits to your STL header files. This
  22. is useful if you want to use one STL source stream for namespace and
  23. non-namespace applications.
  24.  
  25. Good luck and keep the net posted on any workarounds that you discover!
  26.  
  27. Larry Gajdos
  28. (not speaking for HP and in no way affiliated with that part of HP that
  29.  was involved in the STL--and it shows!)
  30.  
  31. #include <new.h>
  32. #include <iostream.h> //rumor has it that pre-including this is also useful!
  33.  
  34. : namespace std
  35. : {
  36. : #include <Vector.h>
  37. : #include <Algo.h>
  38. : }
  39.  
  40.  
  41. : main ()
  42. : {
  43. :     std::vector <int> v;
  44.  
  45. :     v[0] = 1; v [1]=2; v[2]=3;
  46. : }
  47.